<?php

//error_reporting(E_ERROR | E_WARNING | E_PARSE);
set_time_limit(0);
ini_set("memory_limit", "200M");
$conn = @mysql_connect("localhost","root","root");
if (!$conn){
    die("Could not connect£º" . mysql_error());
}

mysql_select_db("faithwar", $conn);
mysql_query("set names 'UTF-8'"); 
date_default_timezone_set("PRC"); //timezone
//$dateTime = date("Y-m-d",strtotime("-1 day"));
$handle = fopen("/usr/share/nginx/www/log/faithwar/logdate.txt", "r");
while (!feof($handle)) {
    $buffer = fgets($handle, 20);
   
    for ($i=1; $i<=200; $i++) {

    $sql = "UPDATE faithwar SET createdate = '$buffer' and date = '$buffer' WHERE id = '$i'";
   if(mysql_query($sql,$conn)){
    echo "更新数据成功！";
  } else {
    echo "更新数据失败：".mysql_error();
  }
    }
}
fclose($handle);
//fclose($fp);
print "Import successful!<br>";

?>
